package cn.ycxy.lbl.posts.utils;

public class RedisKeyUtil {

    private static final String SPLIT = ":";
    /**
     * 点赞
     */
    private static final String PREFIX_ENTITY_LIKE = "cs:like:entity";
    /**
     * 记录想要人数
     */
    private static final String PREFIX_ENTITY_WANT = "cs:want:entity";
    /**
     * 记录帖子浏览人数
     */
    private static final String PREFIX_ENTITY_WATCH = "cs:watch:entity";

    /**
     * 某个实体的赞
     * like:entity:entityType:entityId -> set(userId)
     * @param entityType 点赞实体类型
     * @param entityId  点赞实体id
     * @return
     */
    public static String getEntityLikeKey(int entityType, int entityId) {
        return PREFIX_ENTITY_LIKE + SPLIT + entityType + SPLIT + entityId;
    }

    /**
     * 某个商品浏览的人
     * watch:entity:entityType:entityId -> set(userId)
     * @param entityType 浏览实体类型
     * @param entityId  浏览实体id
     * @return
     */
    public static String getEntityWatchKey(int entityType, int entityId) {
        return PREFIX_ENTITY_WATCH + SPLIT + entityType + SPLIT + entityId;
    }

    /**
     * 某个商品想买的人
     * want:entity:entityType:entityId -> set(userId)
     * @param entityType 想买的实体类型
     * @param entityId  想买的实体id
     * @return
     */
    public static String getEntityWantKey(int entityType, int entityId) {
        return PREFIX_ENTITY_WANT + SPLIT + entityType + SPLIT + entityId;
    }

}
